var hiveMenu = (function () {


  var option={
    context:null,
    data:null,
    sysInfoObj:null,
    windowWidth:0,
    widowHeight:0,
    canvasHeight:0,
    column:5,
    hiveWidth: 0,
    startX:0,
    startY:0
  };

  var hiveMenu = function () { };

  hiveMenu.prototype.init = function (ctx,data,wx) {
    option.context = ctx;
    option.data = data;
    option.sysInfoObj = wx.getSystemInfoSync();
    option.windowWidth =option.sysInfoObj.windowWidth;
    option.windowHeight = option.sysInfoObj.windowHeight;
    option.canvasHeight = option.windowHeight*0.5;
    option.hiveWidth = Math.floor(((option.windowWidth - 10) / option.column))/2;
    option.startX=5+option.hiveWidth;
    option.startY=(option.canvasHeight)/2;
    console.log("开始的X："+option.startX);
    console.log("开始的Y："+option.startY);
    
    console.log("直径是："+option.hiveWidth);
    console.log("高是：" + option.hiveHeight);
    //option.startY = data
    console.log("=====Canvas的高度是：" + option.canvasHeight + "=====");
    //console.log(screenHeight);
    this.addPentagonal(option);
  };

  hiveMenu.prototype.setCanvasPos = function () {

  };

  hiveMenu.prototype.setCanvasStyle = function () {

  };

  hiveMenu.prototype.addPentagonal = function (option) {
        var data = option.data;
        var ctx = option.context;
        var renderColumn=1;
        var renderRow=1;
        var round = option.hiveWidth;
        var paddingY= option.hiveWidth;
        
        var config={
          x: option.startX,
          y: option.startY,
          num:6,
          r: option.hiveWidth
        }
        this.drawPolygon(ctx,config);
        ctx.moveTo(124,100);

        var config = {
          x: round*2+(round/2)+10,
          y: option.startY-round,
          num: 6,
          r: option.hiveWidth
        }

        this.drawPolygon(ctx, config);

        var config = {
          x: round * 2 + (round / 2) + 10,
          y: option.startY + round,
          num: 6,
          r: option.hiveWidth
        }

        this.drawPolygon(ctx, config);

        var config = {
          x: (round * 2) * 2 + 15,
          y: option.startY  ,
          num: 6,
          r: option.hiveWidth
        }

        this.drawPolygon(ctx, config);

        console.log("round is:"+(round*3));
        var config = {
          x: (round * 2)*2 +15,
          y: option.startY + round+round,
          num: 6,
          r: option.hiveWidth
        }

        this.drawPolygon(ctx, config);


        var config = {
          x: (round * 2) * 2 + 15,
          y: option.startY -round-round,
          num: 6,
          r: option.hiveWidth
        }

        this.drawPolygon(ctx, config);




        ctx.draw();





  };

  hiveMenu.prototype.drawPolygon = function (ctx, conf) {
    var x = conf && conf.x || 0;  //中心点x坐标
    var y = conf && conf.y || 0;  //中心点y坐标
    var num = conf && conf.num || 3;   //图形边的个数
    var r = conf && conf.r || 80;   //图形的半径
    var width = conf && conf.width || 5;
    var borderColor = conf && conf.borderCXolor || "orange";
    var fillColor = conf && conf.fillColor || "orange";
    //var strokeStyle = conf && conf.strokeStyle;
    ctx.setStrokeStyle(fillColor);
    ctx.setFillStyle(borderColor);
    var fillStyle = conf && conf.fillStyle;
    //开始路径
    //ctx.beginPath();
    var startX = x + r * Math.cos(2 * Math.PI * 0 / num);
    var startY = y + r * Math.sin(2 * Math.PI * 0 / num);
    ctx.moveTo(startX, startY);
    for (var i = 1; i <= num; i++) {
      var newX = x + r * Math.cos(2 * Math.PI * i / num);
      var newY = y + r * Math.sin(2 * Math.PI * i / num);
      ctx.lineTo(newX, newY);
    }
    //ctx.closePath();
    //路径闭合

    //ctx.strokeStyle = strokeStyle;
    ctx.lineWidth = width;
    ctx.lineJoin = 'round';
    ctx.stroke();
    //ctx.fillStyle = fillStyle;
    ctx.fill();
    ctx.closePath();
  }

  return new hiveMenu();
})();

module.exports.hiveMenu = hiveMenu;

